//
//  InboxDetailViewController.m
//  studip
//
//  Created by Rafael Bugajewski on 07/05/10.
//  Copyright 2010 Juicy Cocktail. All rights reserved.
//

#import "InboxDetailViewController.h"
#import "NSDate-Misc.h"

@implementation InboxDetailViewController

- (void)dealloc
{
	[super dealloc];
}

- (void)didReceiveMemoryWarning
{
  // Releases the view if it doesn't have a superview.
  [super didReceiveMemoryWarning];
  
  // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload
{
  [super viewDidUnload];
  // Release any retained subviews of the main view.
  // e.g. self.myOutlet = nil;
}

- (void)popToLauncherView
{
  [self.navigationController popToRootViewControllerAnimated:YES];
}

- (void)loadView
{
	[super loadView];
  
  [self.navigationItem setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"eingangsbildschirm"] style:UIBarButtonItemStyleBordered target:self action:@selector(popToLauncherView)] autorelease] animated:YES];
  
  self.toolbarItems = [NSArray arrayWithObject:[[[UIBarButtonItem alloc] 
                                                 initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
                                                 target:self action:@selector(addDarthVader)] autorelease]];
  [self.navigationController setToolbarHidden:NO animated:YES];
}

- (void)addDarthVader
{
  [[NSNotificationCenter defaultCenter]
   postNotificationName:@"addDarthVader" object:self];
  
  UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Message added" message:@"This message was added to your home screen for quick navigation." delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil] autorelease];
  [alert show];
}

- (id)init
{
	if (self = [super init])
  {
		self.tableViewStyle = UITableViewStylePlain;
		self.variableHeightRows = YES;
		self.title = @"2 von 7";
    //    
    //    + (id)itemWithTitle:(NSString*)title caption:(NSString*)caption text:(NSString*)text
    //  timestamp:(NSDate*)timestamp imageURL:(NSString*)imageURL URL:(NSString*)URL;
    
    TTTableSubtitleItem *t1 = [TTTableSubtitleItem itemWithText:@"Darth Vader" subtitle:@"Famous man" imageURL:@"bundle://news_darth.png" URL:@"nonexistent"];
    TTTableSubtitleItem *t2 = [TTTableSubtitleItem itemWithText:@"Herrschaft" subtitle:@"3. Juli 2010 14:18"];
    TTTableLongTextItem *t3 = [TTTableLongTextItem itemWithText:@"I find your lack of faith disturbing. You don't know the power of the dark side! Today will be a day long remembered. It has seen the death of Kenobi, and soon the fall of the rebellion. The force is strong with this one.\n\nYou should not have come back! Obi-Wan has taught you well. You are unwise to lower your defenses! No. Leave them to me. I will deal with them myself. You cannot hide forever, Luke. He will join us or die, my master. Alert all commands. Calculate every possible destination along their last known trajectory.\n\nThe force is with you, young Skywalker, but you are not a Jedi yet. What is thy bidding, my master? When I left you I was but the learner.\n\n\n\nNow I am the master."];
    
    self.dataSource = [TTListDataSource dataSourceWithObjects:t1, t2, t3, nil];
    

	}
	
	return self;
}

- (void)viewWillDisappear:(BOOL)animated
{
  [super viewWillDisappear:animated];
  
  [self.navigationController setToolbarHidden:YES animated:YES];
}

@end
